package com.qinggeng.project.api.dto;

import com.google.common.collect.Lists;
import com.qinggeng.framework.aspectj.lang.annotation.Excel;
import com.qinggeng.project.system.domain.UserGift;
import io.swagger.annotations.ApiModel;
import lombok.Data;

import java.util.List;

@Data
@ApiModel("赠品信息")
public class UserGiftDto {

    /** ID */
    private Long userGiftId;

    /** 礼品类型 10=签到礼品 */
    @Excel(name = "礼品类型 10=签到礼品")
    private String giftType;

    /** 商品名称 */
    @Excel(name = "商品名称")
    private String goodsName;

    /** 商品图片 */
    @Excel(name = "商品图片")
    private String goodsImg;

    /** 状态 00=未使用 10=已使用 */
    @Excel(name = "状态 00=未使用 10=已使用")
    private String status;


    public void setGiftType(String giftType) {
        switch (giftType){
            case "10":
                this.giftType = "签到礼品";
                break;
            case "20":
                this.giftType = "新人礼包";
                break;
        }
    }

    public void setStatus(String status) {
        switch (status){
            case "00":
                this.status = "未使用";
                break;
            case "10":
                this.status = "已使用";
                break;
        }
    }

    public static List<UserGiftDto> newsList(List<UserGift> userGiftList) {
        List<UserGiftDto> dtoList = Lists.newArrayList();
        for (UserGift userGift : userGiftList) {
            dtoList.add(news(userGift));
        }
        return dtoList;
    }


    public static UserGiftDto news(UserGift userGift){
        UserGiftDto userGiftDto = new UserGiftDto();
        userGiftDto.setUserGiftId(userGift.getUserGiftId());
        userGiftDto.setGiftType(userGift.getGiftType());
        userGiftDto.setGoodsImg(userGift.getGoodsImg());
        userGiftDto.setGoodsName(userGift.getGoodsName());
        userGiftDto.setStatus(userGift.getStatus());
        return userGiftDto;
    }

}
